package com.etc.test2;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author MaZheng
 * @since 2020/12/23 - 10:59
 */
@Component
public class Emp {

//    @Value("tom")

    private String name;
    private String id;

    // 依赖注入
    // Resource()默认 byname
    // byname根据类的 名字@Component("dept1")
    // bytype根据类型 type=@Resource(type=Dept2.class)
//    @Resource(type=Dept2.class)

    //
    @Autowired
    @Qualifier("dept2")
    private IDept dept;


    @Bean
    public Date newInstance() {
        return new Date();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public IDept getDept() {
        return dept;
    }

    public void setDept(IDept dept) {
        this.dept = dept;
    }
}
